﻿using System;
using System.Text;
using SecretLabs.NETMF.Hardware;
using Netduino.Sensor.Unit;

namespace Netduino.Sensor
{
    /// <summary>
    /// A sensor which in effect is just a wrapper around the values of an analog input
    /// </summary>
    public class NakedSensor: ISensor
    {
        /// <summary>
        /// The analog input to use for this sensor
        /// </summary>
        private AnalogInput analogInput;

        /// <summary>
        /// Create a new instance with the specified input for capturing values.
        /// </summary>
        /// <param name="analogInput"></param>
        public NakedSensor(SecretLabs.NETMF.Hardware.AnalogInput analogInput)
        {            
            this.analogInput = analogInput;
        }

        /// <summary>
        /// Takes a sample from the analog input.
        /// </summary>
        /// <returns></returns>
        public ISample Take()
        {
            return new Sample(analogInput.Read(), _nakedUnit);
        }

        /// <summary>
        /// Unspecified unit
        /// </summary>
        private IUnit _nakedUnit = new SpecifiedUnit("1", "1");


        /// <summary>
        /// Gets the caption of this sensor.
        /// </summary>
        public string Caption
        {
            get
            {
                return "raw sensor value";
            }
        }
    }
}
